<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/jquery/jquery.js"></script>
</head>
<body>
    <input id="mgic-input" type="text" value=""  style="width: 50%;">
    <button id="mgic" onclick="fileListLoad(this);">抓取</button>
    <br/>
    <input id="mgic-input2" type="text" value=""  style="width: 50%;">
    <button id="mgic2" onclick="fileListLoad2(this);">抓取2</button>
    <div id="console-box"></div>
    <script>
        /**
         * 获取根目录
         */
        window.getHost = function () {
            var domain = "http://"+window.location.host+'';
            return domain;
        };
        //ajax 请求 file-select
        function fileListLoad() {
            $.ajax({
                type: "post",
                async: true,
                url: getHost()+'/mgic?v='+Math.random(),
                dataType: "json",
                data:{'basePath':$('#mgic-input').val()},
                success: function(data){
                    console.log(data);
                    $('#console-box').empty().append(JSON.stringify(data));
                },
                error: function(){
                }
            });
        };
        function fileListLoad2() {
            $.ajax({
                type: "post",
                async: true,
                url: getHost()+'/mgic2?v='+Math.random(),
                dataType: "json",
                data:{'basePath':$('#mgic-input2').val()},
                success: function(data){
                    console.log(data);
                    $('#console-box').empty().append(JSON.stringify(data));
                },
                error: function(){
                }
            });
        };
    </script>
</body>
</html>